package com.ypj.rpc.loaderbalancer;

import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;

/**
 * 轮盘算法
 */
public class RoundRobinLoadBalancer implements LoaderBalancer {

    private int index;

    @Override
    public Instance select(List<Instance> instances) {
        if (index>=instances.size()){
            index%=instances.size();
        }
        return  instances.get(index);
    }
}
